import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store/index.js'
import Layout from '@/views/layout/Layout.vue'//最大路由
import Home from '@/views/home/Home.vue'//首页
const Rank = ()=>import('@/views/rank/Rank.vue')//排行榜
const PlayList =()=>import('@/views/playlist/PlayList.vue')//全部歌单
const Songsheet = ()=>import('@/views/playlist/Songsheet.vue')//歌单详情
const MvList =()=>import('@/views/mv/MvList.vue')//全部mv
const Mv =()=>import('@/views/mv/Datil.vue')//mv
const Artist =()=>import('@/views/artist/Artist.vue')//全部歌手
const MyMsice =()=>import('@/views/my/MyMsice.vue')//未实现
const Search =()=>import('@/views/search/Search.vue')//搜索
const Album =()=>import('@/views/album/index.vue')//专辑
const Song =()=>import('@/views/song/index.vue')//歌曲详情
const Singer = ()=>import('@/views/artist/singer.vue');//歌手详情
Vue.use(VueRouter)

const routes = [
  { 
    path:'',
    component:Layout, //最大的路由，相当于app.vue(解放app.vue)
    children:[
      {
        path:'/',
        name:'Home',
        component:Home
      },
      {
        path:'/search',
        name:'Search',
        component:Search
    
      },
      {
        path:'/rank',
        name:'Rank',
        component:Rank
      },
      {
        path:'/playlist',
        name:'PlayList',
        component:PlayList
      },
      {
        path:'/songsheet',
        name:'Songsheet',
        component:Songsheet
      },
      {
        path:'/mvlist',
        name:'MvList',
        component:MvList
      },
      {
        path:'/mv',
        name:'Mv',
        component:Mv
      },
      {
        path:'/artist',
        name:'Artist',
        component:Artist
      },
      {
        path:'/singer',
        name:'Singer',
        component:Singer
      },
      {
        path:'/album',
        name:'Album',
        component:Album
      },
      {
        path:'/song',
        name:'Song',
        component:Song
      },
      {
        path:'/my',
        name:'MyMsice',
        component:MyMsice
      }
    ]
  },
  
]

const router = new VueRouter({
  routes
})
router.beforeEach((to,from,next)=>{
  if(to.path==='/my'){
    store.commit('setloginDialogVisible',true);
  }else{
    next()
  }
})
export default router
